"""
删除语句
"""
from pymysql import Connection
conn = None
try:
    conn = Connection(
        host='localhost',
        port=3306,
        user='root',
        passwd='root',
        charset='utf8',
        database='db2',
        autocommit=True
    )

    cursor = conn.cursor()
    sql = """
        delete from t_user where id = 2
    """
    cursor.execute(sql)
    print('删除成功')
except Exception as e:
    print(e)
finally:
    if conn:
        conn.close()